package com.hoshiicloud.payment.feign.fallback;

import com.hoshiicloud.common.rpc.Response;
import com.hoshiicloud.payment.feign.UserFeignService;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * @program: hoshiicloud
 * @description: 平台服务熔断
 * @author: Mr.wu
 * @create: 2019-05-27 11:45
 **/
@Component
@Slf4j
public class UserFeignFallbackFactory implements FallbackFactory<UserFeignService> {

    @Override
    public UserFeignService create(Throwable throwable) {
        log.error("fallback; reason was:" + throwable.toString());
        return id -> {
            //TODO 服务降级
            return Response.failed("平台服务出错");
        };
    }
}
